﻿using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RK.SerivesPlugin.BPW
{
    [Description("销售订单整单关闭时，把明细行的业务状态也关闭"), HotUpdate]
    public class DzYLBillClose : AbstractOperationServicePlugIn
    {
        public override void EndOperationTransaction(EndOperationTransactionArgs e)
        {
            base.EndOperationTransaction(e);
            var obj = e.DataEntitys.FirstOrDefault();
            //var formId = this.BusinessInfo.GetForm().Id;
            //var operationNumber = this.FormOperation.Operation;
            var id = Convert.ToInt32(obj["Id"]);
            string sqlStr = string.Format($@"/*dialect*/ UPDATE T1 SET T1.FMRPCLOSESTATUS='B' 
            FROM T_SAL_ORDER T0
            JOIN T_SAL_ORDERENTRY T1 ON T1.FID=T0.FID
            WHERE T0.FID={id}");
            DBServiceHelper.Execute(this.Context, sqlStr);
        }
    }
}
